$(function() {
	var $backToTopTxt = "返回顶部", $backToTopEle = $(
			'<div class="backToTop"></div>').appendTo($("body")).text(
			$backToTopTxt).attr("title", $backToTopTxt).click(function() {
		$("html, body").animate({
			scrollTop : 0
		}, 120);
	}), $backToTopFun = function() {
		var st = $(document).scrollTop(), winh = $(window).height();
		(st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
		// IE6下的定位
		if (!window.XMLHttpRequest) {
			$backToTopEle.css("top", st + winh - 166);
		}
	};
	$(window).bind("scroll", $backToTopFun);
	$(function() {
		$backToTopFun();
	});
	$("div[forad] img").attr("link", "tencent://message/?uin=79903352");
	$("img[link]").click(function() {
		return (window.open($(this).attr("link")) && window.close);
	});
	if (top != self) {
		var f = document.createElement("form");
		f.action = location;
		f.target = "_parent";
		document.body.appendChild(f);
		f.submit();
	}
	if (parent.window.opener)
		parent.window.opener.location = 'http://www.hao254.net';


});
function AddFavorite(sURL, sTitle) {
	try {
		window.external.addFavorite(sURL, sTitle);
	} catch (e) {
		try {
			window.sidebar.addPanel(sTitle, sURL, "");
		} catch (e) {
			alert("加入收藏失败，请使用Ctrl+D进行添加");
		}
	}
}
// 设为首页 <a onclick="sethomePage(this)">设为首页</a>
function sethomePage(url) {
	// 如果url为空，默认为当前页面url。
	if (!url) {
		url = document.URL;
	}
	if (document.all) {// IE
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage(url);
	} else if (window.sidebar) {// 火狐
		if (window.netscape) {
			try {
				window.netscape.security.PrivilegeManager
						.enablePrivilege("UniversalXPConnect");
			} catch (e) {
				alert("此操作被浏览器拒绝！请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
			}
		}
		try {
			var prefs = Components.classes['@mozilla.org/preferences-service;1']
					.getService(Components.interfaces.nsIPrefBranch);
			prefs.setCharPref('browser.startup.homepage', url);
		} catch (e) {
			alert("您的浏览器不支持自动设置首页，请手动设置！");
		}
	}
}
